/*
* @Author: song
* @Description:脚本流水线系统
* @Date: 2024年04月18日 星期四 14:04:14
* @Modify:
*/

using System.Collections.Generic;
using SCore.Util;

namespace SCore.Function.ScriptPipeline
{
    public class ScriptPipelineSystem : IComponent, IUpdatable
    {
        //所有流水线集合
        private List<ScriptPipeline> _pipelines = new List<ScriptPipeline>();

        public void Init()
        {
            UnityUpdate.Instance.Register(this);
        }

        public void Clear()
        {
            UnityUpdate.Instance.UnRegister(this);
        }


        //得到流水线
        public ScriptPipeline Get()
        {
            ScriptPipeline sPipeline = new ScriptPipeline();
            _pipelines.Add(sPipeline);
            return sPipeline;
        }

        public void Stop(ScriptPipeline sPipeline)
        {
            if (_pipelines.Contains(sPipeline))
                _pipelines.Remove(sPipeline);
        }

        public void SUpdate(float dt)
        {
            for (int index = _pipelines.Count - 1; index >= 0; index--)
            {
                _pipelines[index].SUpdate(dt);
            }
        }
    }
}